

package com.hazelcast.client.map.impl.iterator;

import com.hazelcast.client.impl.proxy.ClientMapProxy;

import javax.annotation.Nonnull;
import java.util.Iterator;
import java.util.Map;

/**
 * Client-side iterable that provides an iterator for iterating map
 * entries in the specified partition.
 * It returns {@link ClientMapPartitionIterator}.
 *
 * @param <K> the key type of map.
 * @param <V> the value type of map.
 * @see ClientMapPartitionIterator
 */
public class ClientMapPartitionIterable<K, V> implements Iterable<Map.Entry<K, V>> {
    private final ClientMapProxy<K, V> clientMapProxy;
    private final int fetchSize;
    private final int partitionId;
    private final boolean prefetchValues;

    public ClientMapPartitionIterable(ClientMapProxy<K, V> clientMapProxy, int fetchSize, int partitionId, boolean prefetchValues) {
        this.clientMapProxy = clientMapProxy;
        this.partitionId = partitionId;
        this.fetchSize = fetchSize;
        this.prefetchValues = prefetchValues;
    }

    @Nonnull
    @Override
    public Iterator<Map.Entry<K, V>> iterator() {
        return clientMapProxy.iterator(fetchSize, partitionId, prefetchValues);
    }
}
